﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace DarkNeuron.Services.Input
{
	public sealed class ButtonManager : GameComponent
	{
		static List<Button> listButtons;
		public static bool Initialized { get; private set; }


		public ButtonManager(Game game)
			: base (game)
		{
			if (!Initialized)
				Initialize();
		}


		private void Initialize()
		{
			// Initializes lit of buttons
			listButtons = new List<Button>();

			Initialized = true;
		}

		public override void Update(GameTime gameTime)
		{
			foreach (Button button in listButtons)
				button.Update(gameTime);
			

			base.Update(gameTime);
		}

		public static bool CheckExistingName(string checkName)
		{
			foreach (Button button in listButtons)
				if (button.Name == checkName)
					return true;
			return false;
		}

		internal static bool AddButton(Button buttonKeyboard)
		{
			// TODO: Check if button already exists
			listButtons.Add(buttonKeyboard);
			return true;
		}
	}
}
